function isValidEmailAddress(emailAddress) 
{
	var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
	return pattern.test(emailAddress);
}

$(document).ready(function(){		
	//**************************************************************************/
	$("#submit_book_tour1").click(function(){
			
		var agent_name 		= $("#agent_name").val();
		var agent_email 	= $("#agent_email").val();
		var agent_address 	= $("#agent_address").val();
		var agent_phone 	= $("#agent_phone").val();		
		var agent_message 	= $("#agent_message").val();
		
		var company_security = $("#captcha").val();
		
		var check_in_dy_ticket = $("#check_in_dy_ticket").val();
		var check_in_mo_ticket = $("#check_in_mo_ticket").val();
		var check_in_yr_ticket = $("#check_in_yr_ticket").val();
		
		var check_out_dy_ticket = $("#check_out_dy_ticket").val();
		var check_out_mo_ticket = $("#check_out_mo_ticket").val();
		var check_out_yr_ticket = $("#check_out_yr_ticket").val();	
		
		var adults_ticket = $("#adults_ticket").val();
		var transport_ticket = $("#transport_ticket").val();
		var from_ticket = $("#from_ticket").val();
		var to_ticket = $("#to_ticket").val();
		
		
		
		var tamp = "";
		if(adults_ticket=="")
		{
			$("#contact_error_adults_ticket").removeClass('contact_error');
			$("#contact_error_adults_ticket").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_adults_ticket").removeClass('contact_error_show');
			$("#contact_error_adults_ticket").addClass('contact_error');
		}
		/*---------------------------------------------------------*/
		if(transport_ticket=="")
		{
			$("#contact_error_transport_ticket").removeClass('contact_error');
			$("#contact_error_transport_ticket").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_transport_ticket").removeClass('contact_error_show');
			$("#contact_error_transport_ticket").addClass('contact_error');
		}
		/*---------------------------------------------------------*/
		if(from_ticket=="")
		{
			$("#contact_error_from_ticket").removeClass('contact_error');
			$("#contact_error_from_ticket").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_from_ticket").removeClass('contact_error_show');
			$("#contact_error_from_ticket").addClass('contact_error');
		}
		/*---------------------------------------------------------*/
		
		if(to_ticket=="")
		{
			$("#contact_error_to_ticket").removeClass('contact_error');
			$("#contact_error_to_ticket").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_to_ticket").removeClass('contact_error_show');
			$("#contact_error_to_ticket").addClass('contact_error');
		}
		/*---------------------------------------------------------*/
		if(agent_name=="")
		{
			$("#contact_error_name").removeClass('contact_error');
			$("#contact_error_name").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_name").removeClass('contact_error_show');
			$("#contact_error_name").addClass('contact_error');
		}
		/*---------------------------------------------------------*/
		if(agent_email=="" || !isValidEmailAddress(agent_email))
		{
			$("#contact_error_email").removeClass('contact_error');
			$("#contact_error_email").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_email").removeClass('contact_error_show');
			$("#contact_error_email").addClass('contact_error');
		}
		/*---------------------------------------------------------*/
		if(agent_address=="")
		{
			$("#contact_error_address").removeClass('contact_error');
			$("#contact_error_address").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_address").removeClass('contact_error_show');
			$("#contact_error_address").addClass('contact_error');
		}
		/*---------------------------------------------------------*/
		if(agent_phone=="")
		{
			$("#contact_error_phone").removeClass('contact_error');
			$("#contact_error_phone").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_phone").removeClass('contact_error_show');
			$("#contact_error_phone").addClass('contact_error');
		}
		
		/*---------------------------------------------------------*/
		if(agent_message=="")
		{
			$("#contact_error_message").removeClass('contact_error');
			$("#contact_error_message").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_message").removeClass('contact_error_show');
			$("#contact_error_message").addClass('contact_error');
		}
		
		/*---------------------------------------------------------*/
		if(company_security=="")
		{
			$("#contact_error_captcha").removeClass('contact_error');
			$("#contact_error_captcha").addClass('contact_error_show');
			tamp += "ten";
		}
		else
		{
			$("#contact_error_captcha").removeClass('contact_error_show');
			$("#contact_error_captcha").addClass('contact_error');
		}
		
		
		if(tamp!="")
			return false;
		else
			return true;
		/*
		else
		{
			var url =  $("#myprocess_url").val();	
			var show =  $("#myprocess_show_result").val();	
						
			var agentString = agent_name+'*|*'+agent_email+'*|*'+agent_address+'*|*'+agent_phone+'*|*'+agent_message;
			var companyString = company_name+'*|*'+company_email+'*|*'+company_address+'*|*'+company_phone+'*|*'+company_fax+'*|*'+company_message;
			url = url + "?action=travel-agent&agent="+agentString+'&company='+companyString;			
			dbagentsend(url,show);
		}
		*/		
	});	
});